﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace BulldogCMS.Core.MVC
{
    public class ControllerFactory : System.Web.Mvc.IControllerFactory
    {
        public System.Web.Mvc.IController CreateController(System.Web.Routing.RequestContext requestContext, string controllerName)
        {
            var obj = HttpContext.Current.Request;
            if (Context.Request != null && Context.Request.CurrentControllerName != null)
            {
                return Context.Request.CurrentControllerName.Instantiate<IController>();
            }
            else if (Context.Request.CurrentModuleAreaProvider != null)
            {
                return Context.Request.CurrentModuleAreaProvider.CreateController(requestContext, controllerName);
            }
            throw new NotImplementedException();
        }

        public System.Web.SessionState.SessionStateBehavior GetControllerSessionBehavior(System.Web.Routing.RequestContext requestContext, string controllerName)
        {
            return System.Web.SessionState.SessionStateBehavior.Default;
            //throw new NotImplementedException();
        }

        public void ReleaseController(System.Web.Mvc.IController controller)
        {
            //throw new NotImplementedException();
        }
    }
}